<template>
  <div>
    <van-image 
      width="100%"
      src="/images/Confirm/confirm.svg"
    />
    <p style="text-align: center">您已提交订单,{{time}}s后将返回首页</p>
    <van-button type="info" size="small" style="display:block; margin: 1rem auto" @click="time=0">点击返回首页</van-button>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        time: 5,
        home: ''
      }
    },
    mounted () {
      this.home=setInterval(() => {
        this.time--
      }, 1000);
    },
    watch: {
      time(newValue, oldValue) {
        if(newValue==0){
          let order_number=this.$route.query.id
          // let order_number=202111251247
          clearInterval(this.home);
          this.$get('/v1/order/paid',{order_number}).then(res=>{
          //console.log(res);
          })
          this.$router.push('/home')
        }
      }
    },
  }
</script>

<style lang="scss" scoped>

</style>